const knex = require('../db/knex');

class UserModel {
  static async createUser(user) {
    return await knex('users').insert(user).returning('*');
  }

  static async getUserByUsername(username) {
    return await knex('users').where({ username }).first();
  }

  static async getUserById(userId) {
    return await knex('users').where({ user_id: userId }).first();
  }
 static async updateVirtualCurrency(userId, amount) {
  return await knex('users')
    .where({ user_id: userId })
    .increment('virtual_currency', amount)
    .returning('*');
}
}

module.exports = UserModel;